package com.zrrd.mapper;

import com.zrrd.pojo.Tea;
import com.zrrd.utils.BuildTeaSql;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author WanJl
 * @version 1.0
 * @title TeaMapper02
 * @description
 * @create 2024/1/23 16:38
 */
public interface TeaMapper03 {
    /**
     *  查询所有
     * @return
     */
    @SelectProvider(type = BuildTeaSql.class, method ="getSelectAll" )
    List<Tea> queryTeaAll();

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @SelectProvider(type = BuildTeaSql.class, method ="getSelectById")
    Tea queryOneById(Integer id);

    /**
     * 插入
     * @param tea
     * @return
     */
    @Insert("INSERT INTO jms2301_db01.tea (teaName, teaTypeId, ordered, description, status) VALUES (#{teaName},#{teaTypeId},#{ordered},#{description},#{status})")
    Integer insertTea(Tea tea);

    /**
     * 修改
     * @param tea
     * @return
     */
    @Update("UPDATE jms2301_db01.tea\n" +
            "        SET teaName=#{teaName},\n" +
            "            teaTypeId=#{teaTypeId},\n" +
            "            ordered=#{ordered},\n" +
            "            description=#{description},\n" +
            "            status=#{status}\n" +
            "        WHERE id=#{id}")
    Integer updateTea(Tea tea);

    /**
     * 删除
     * @param id
     * @return
     */
    @Delete("DELETE FROM jms2301_db01.tea WHERE id=#{id}")
    Integer deleteTea(Integer id);

}

